Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

namespaced users/session controllers cause rspec stories to fail.

#13

I am using namespaces for both my UsersController and my SessionController.

When I was updating my rspec stories to use the namespaces, I wasn't able to get some to pass.

Lines such as "When she creates a singular admin/admin_sessions ..." would try to post to 'admin'. The '/' was not consumed by the regex.

The following change seemed to fix the problem.

=================================

ra_navigation_steps.rb

When %r{$actor creates an? $resource with $attributes} do |actor, resource, attributes|

attributes = attributes.to_hash_from_story

  • if resource =~ /singular (\w+)/
  • if resource =~ /singular ([\w\/]+)/ resource = $1.downcase.singularize post "/#{resource}", attributes else post "/#{resource.downcase.pluralize}", { resource.downcase.singularize => attributes } end end

Reported by Paul Cortens · September 3rd, 2008 @ 04:45 AM

State: new
Milestone: none
Assigned to: nobody

Activity

  1. Paul Cortens
    Paul Cortens

    Here is a reposting of the code snippet:

    
    ==================================
    ra_navigation_steps.rb
    ==================================
    
      When %r{$actor creates an? $resource with $attributes} do |actor, resource, attributes|
        attributes = attributes.to_hash_from_story
    -    if resource =~ /singular (\w+)/
    +    if resource =~ /singular ([\w\/]+)/
          resource = $1.downcase.singularize
          post "/#{resource}", attributes
        else
          post "/#{resource.downcase.pluralize}", { resource.downcase.singularize => attributes }
        end
      end
    

    September 3rd, 2008 @ 04:48 AM

  2. mrflip
    mrflip
    • Tag set to generated, install, model, nested

    Thanks for the patch, fix applied.

    Just curious -- can you present the use case for a nested controller? As in, what problem does it solve?

    Would a super-simple three-roles role system (non-activated user, user, admin) meet the same needs, if that came as a separate plugin guaranteed to work simply with restful authentication?

    I've been arguing for some changes that will make this much harder but other things easier.

    September 4th, 2008 @ 03:20 PM

  3. Paul Cortens
    Paul Cortens
    • Assigned user cleared.
    • Tag changed from generated, install, model, nested to generated, install, model, nested, rspec, stories

    The application I was working on when I found this is a small CMS. It will be used as the basis for several project we have. We thought it would be a little cleaner to have all the CMS/admin code in a namespace. Having nested routes kept in line with it so that when we reference our URLs with admin_my_model_path it is always clear in code that the url is for admin stuff.

    Overall it isn't a super high value use case. If you have changes that add more value then I don't think anyone loses much by not making the change I suggested.

    September 6th, 2008 @ 01:49 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.